var express = require('express'),
    path = require('path'),
		compression = require('compression')

var app = express()

// must be first!
if(process.env.NODE_ENV === 'production')
	app.use(compression())

//point to the right directory for static assets
app.use(express.static(path.join(__dirname, 'public')))

// send all requests to index.html so browserHistory in React Router works
app.get('*', function (req, res) {
  res.sendFile(path.join(__dirname, 'public', 'index.html'))
})

var PORT = process.env.PORT || 9527
app.listen(PORT, function() {
  console.log('Production Express server running at http://localhost:' + PORT)
})
